package blog.caidabao.service;

import blog.caidabao.mapper.CategoryMapper;
import blog.caidabao.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    /**
     * 查询所有分类
     * @return
     */
    public List<Category> categeryAll(){
        return categoryMapper.selectAll();
    }

    /**
     * 根据id删除category
     * @param id
     * @return
     */
    public Boolean categoryDelete(Integer id) {
        if(categoryMapper.deleteByPrimaryKey(id)==1){
         return true;
        }
        return false;
    }

    /**
     * 新建category
     * @param category
     * @return
     */
    public Boolean categorySave(Category category) {
        if(categoryMapper.insert(category)==1){
            return true;
        }
        return false;
    }
}
